V = Variables
C = Claculation functions
The VC21LPFilter function implements a low-pass digital filter of the first order for values in the range from -999999 to +999999. It ' also provided the pre-charge filter option.
VC20LPFilter (Mode, Tsample, Tau, FilterIn, FilterOut)
Parameters:
| IN/OUT | VARIABLE TYPE | EXAMPLE NAME | DIM | |
|---|---|---|---|---|
| IN | CONST / GLOBAL | Mode | F | Mode of operation (0=pre-charge, 1=filter execution). |
| IN | CONST / SYSTEM | Tsample | W | Sample time filter (msec) [0÷32767]. |
| IN | CONST / SYSTEM | Tau | W | The filter time constant (ms) [0÷32767] |
| IN | GLOBAL | FilterIn | L | Value of the variable that you want to filter [-999999÷999999] |
| OUT | GLOBAL | FilterOut | L | Value of the filtered variable [-999999÷999999] |
The VC21LPFilter function implements a digital low-pass filter of the first order whose time constant (Tau) is defined in the parameters passed to the function. Assuming you start from a zero input variable value, the output of the filter takes a value equal to 63% of the input after the long Tau. Similarly the cutoff frequency of the filter is
. If the Mode topic is zero allows you to preload the filter to a value that can be set with the topic FilterIn.
;---------------------------------------------
; Project : REG_012
; Module Name : ReadTemp
; Author :
; Description : Read temperature & filter
;---------------------------------------------
MAIN:
CALL ReadTemp
swTsample = 100 ;100 ms tempo campionamento filtro
swTau = 5000 ;5 sec costante di tempo filtro
gfMode = 1 ; normale esecuzione
VC21LPFilter (gfMode,swTsample, swTau, gwFilterIn, gwFilterOut)
WAIT 1
JUMP MAIN